package session;

import javax.servlet.ServletException;
import javax.servlet.http.*;
import java.awt.image.BufferedImage;
import java.io.IOException;

import cn.lkk.utils.VerifyCode;

/**
 * 用于生成一个验证码
 */
public class VerifyCodeGenerator extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        VerifyCode vc = new VerifyCode();
        BufferedImage img = vc.getImage();
        req.getSession().setAttribute("vcText", vc.getText());
        VerifyCode.output(img, resp.getOutputStream());
    }
}
